package state.font;

import particle.core.tools.VectorInt;
import particle.core.view.TextDraw;
import particle.core.view.assets.Font;
import state.Clip;
import state.GameConstants;
import state.Graphics;
import state.component.GameScrollBar;

public class ImageTextImpl extends ImageFontImpl implements ImageText {
  private TextDraw textDraw = new TextDraw();

  public ImageTextImpl(Font font1, Font boldFont1) {
    super(font1, boldFont1);
  }

  public int drawParagraph(Graphics g, String text, int color, int width, int x, int y) {
    g.setColor(color);
    rect.left = x;
    rect.right = x + width;
    rect.top = y;
    rect.bottom = y + GameConstants.SCREEN_HEIGHT;
    g.getSystemGraphics().prepareText(text, currentUseFont, rect, GameConstants.TOP_LEFT_ANCHOR, true, false, textDraw);
    g.getSystemGraphics().drawPreparedText(textDraw);
    VectorInt lineYs = textDraw.lineYPositions;
    return lineYs.get(lineYs.size() - 1) + getHeight();
  }

  public int drawParagraph1(Graphics g, String text, int color, int width, int lineDistance, int x, int y) {
    return drawParagraph(g, text, color, width, x, y);
  }

  public int drawParagraph2(Graphics g, String text, int color, int width, int x, int y, GameScrollBar bar) {
    Clip.getClip1(g, reuseClip);
    bar.getView().clipRect(g);
    int lastY = drawParagraph(g, text, color, width, x, y);
    bar.updateScroll(y, lastY);
    reuseClip.applyClip(g);
    return lastY;
  }

  public void prepareCache1(String[] texts, int width) {
  }

  public void prepareCache(String text, int width) {
  }
}
